package com.ebupt.migu.music.reco.controller;

import com.ebupt.migu.music.common.auth.IDAuthUtils;
import com.ebupt.migu.music.common.entity.ResultObject;
import com.ebupt.migu.music.common.util.ReqestParamUtil;
import com.ebupt.migu.music.reco.service.RecoService;
import com.ebupt.migu.music.reco.utils.RecoESUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @Author liuyangyang@ebupt.com
 * @Description
 * @Date 2021/11/10 16:48
 */
@RestController
@RequestMapping("/reco")
public class RecoController {

    @Autowired
    private IDAuthUtils idAuthUtils;
    @Autowired
    private RecoService recoService;
    @Autowired
    private HttpServletRequest request;

    /**
     * 查询场景类型
     *
     * @return
     */
    @RequestMapping("/scenes")
    public ResultObject scenes() {
        return recoService.queryScenes();
    }

    /**
     * 创建资源下线信息记录&资源下线状态记录
     *
     * @return
     */
    @RequestMapping("/create")
    public ResultObject create() {
        Map<String, Object> params = ReqestParamUtil.getParamsWithUserInfo(request);
        return recoService.create(params);
    }

    /**
     * 查询资源下线信息列表
     *
     * @return
     */
    @RequestMapping("/list")
    public ResultObject queryRes() {
        Map<String, Object> params = ReqestParamUtil.getParamsWithUserInfo(request);
        params = idAuthUtils.isAdmin(params);
        return recoService.queryRes(params);
    }

    /**
     * 查询资源明细
     *
     * @return
     */
    @RequestMapping("/query")
    public ResultObject query() {
        Map<String, Object> params = ReqestParamUtil.getParams(request);
        return recoService.query(params);
    }

}
